package cn.itsource.pethome.service.impl;

import cn.itsource.pethome.domain.Department;
import cn.itsource.pethome.mapper.DepartmentMapper;
import cn.itsource.pethome.query.DepartmentQuery;
import cn.itsource.pethome.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class DepartmentServiceImpl extends BaseServiceImpl<Department, DepartmentQuery>
        implements IDepartmentService {

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    private DepartmentMapper departmentMapper;

    /**
     * 查询部门
     * @param findParent 1表示查询父级部门  2表示查询子部门
     * @return
     */
    @Override
    public List<Department> findAllParent(Integer findParent) {
        return departmentMapper.findAllParent(findParent);
    }


    /**
     * 通过部门名称查询部门
     * @param name
     * @param id
     * @return
     */
    @Override
    public Department findByName(String name,Long id) {
        return departmentMapper.findByName(name,id);
    }
}
